/**
 * @author YinHang
 * desktop
 */
;(function () {
	var Desktop = {
			show: showDesktop,
			hide: hideDesktop
	};
	
	var loaded = false;
	
	function showDesktop(callback) {
		$("div.right").children(":not(div.widget-system)").fadeOut(150, function () {
			var content = $(this);
			if(loaded)
			{
				$("div.widget-system").fadeIn(150, function () {
					if(callback)
						callback();
				});
				return;
			}
			var ws = new WidgetSystem({
				path: path,
				parent: $("div.right:first"),
				rows: 3,
				positionUpdate: function (id, col, row) {
					
				},
				widgetExit: function (id) {
					
				}
			});
			//static list
			ws.render([
			       		{
				       		id: 1,
			       			uri: "/widget/weather",
			       			row: 1,
			       			position: 1
			       		},
			       		{
				       		id: 2,
			       			uri: "/widget/calendar",
			       			row: 3,
			       			position: 1
			       		},
			       		{
				       		id: 3,
			       			uri: "/widget/news",
			       			row: 2,
			       			position: 1
			       		}
			       	]);
			loaded = true;
			if(callback)
				callback();
		});
	};
	
	function hideDesktop(callback) {
		$("div.widget-system").fadeOut(150, function () {
			$("div.right").children(":not(div.widget-system)").fadeIn(150);
			if(callback)
				callback();
		});
	};
	
	window.Desktop = Desktop;
})();